package com.bangbang.blog.controller;


import com.bangbang.blog.pojo.TbStudentUser;
import com.bangbang.blog.service.impl.TbStudentUserServiceImpl;
import com.bangbang.configresult.Result;
import com.bangbang.configresult.ResultEnum;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-08-13
 */
@Controller
@RequestMapping("/blog/tbStudentUser")
public class TbStudentUserController {

    @Autowired
    private TbStudentUserServiceImpl tbStudentUserService;

    //修改
    @PutMapping
    @ApiOperation("用户修改方法")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tbStudentUser",value = "用户的实体类",required = true,paramType = "body")
    })
    public Result update(@RequestBody TbStudentUser tbStudentUser){
        tbStudentUserService.updateById(tbStudentUser);
        return Result.buildResult(ResultEnum.SUCCESS);
    }

    //删除
    @DeleteMapping
    @ApiOperation("用户的删除方法")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId",value = "用户的id",required = true,paramType = "query")
    })
    public Result delete(@RequestParam(required = true)Long userId){
        tbStudentUserService.delete(userId);
        return Result.buildResult(ResultEnum.SUCCESS);
    }

    //查询
    @GetMapping
    @ApiOperation("用户的查询方法")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId",value = "用户的id",required = true,paramType = "query")
    })
    public Result select(@RequestParam(required = true)Long userId){
        tbStudentUserService.select(userId);
        return Result.buildResult(ResultEnum.SUCCESS);
    }
}

